<?php
    class Model_Tin extends Zend_Db_Table_Abstract{
        public $_name="tin";
        public $_primary="idtin";
        public function getAll()
        {
            $se=  $this->select();
            return $this->fetchAll($se)->toArray();
        }
        public function getAlluser($iduser)
        {
            $se=  $this->select();
            $se->where("iduser=?",$iduser);
            return $this->fetchAll($se)->toArray();
        }
        public function getWhere($idtin)
        {
            $se=  $this->select();
            $se->where("idtin=?",$idtin);
            return $this->fetchAll($se)->toArray();
        }
        public function getWheretheloai($idtl)
        {
            $se=  $this->select();
            $se->where("idtl=?",$idtl);
            return $this->fetchAll($se)->toArray();
        }
        public function getWhereloaitin($idtl,$idlt)
        {
            $se=  $this->select();
            $se->where("idtl=?",$idtl);
            $se->where("idlt=?",$idlt);
            return $this->fetchAll($se)->toArray();
        }
        
        public function seachnew($search){
		$se = $this->select();
		$se->where("noidungtin LIKE '%$search%'");
		return $this->fetchAll($se)->toArray();
	}
        public function timTieude($tim){
		$se = $this->select();
		$se->where("tieude LIKE '%?%'",$tim);
		return $this->fetchAll($se)->toArray();
	}
        public function getUnlock()
        {
            $se=  $this->select();
            $se->where("anhien='0'");
            return $this->fetchAll($se)->toArray();
        }
        public function getUnlockcount()
        {
            $se=  $this->select();
            $se->where("anhien='0'");
            $usr= $this->fetchAll($se)->toArray();
            return count($usr);
        }
        public function getLock()
        {
            $se=  $this->select();
            $se->where("anhien='2'");
            return $this->fetchAll($se)->toArray();
        }
        public function setLock($data,$idtin)
        {
            $kq = $this->update($data,"idtin=$idtin");
            if($kq){
			return true;
            }
            else{
			return false;
            }
        }
        public function setUnlock($data,$idtin)
        {
            $kq = $this->update($data,"idtin=$idtin");
            if($kq){
			return true;
            }
            else{
			return false;
            }
        }
        public function insertTin($data)
        {
            $kq = $this->insert($data);
		if($kq)
			return true;
		else
			return false;
        }
    }
?>
